<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template.xhtml">
	<ui:define name="tituloPagina">
		<p:outputLabel value="Consultar Compromissos" />
	</ui:define>
	<ui:define name="botoes">
		<p:commandButton icon="ui-icon-search"
			action="#{compromissoBean.listarByFiltros}" value="Consultar"
			update="tabela" />
	</ui:define>

	<ui:define name="principal">





		<style type="text/css">
.pedente {
	background-color: #006fC2;
	color: #fff;
}

.solicitado {
	background-color: #7EC0EE;
	color: #000;
}

.proximoMeta {
	background-color: #F9FFA5;
	color: #000;
}

.atrasado {
	background-color: #CD5555;
	color: #fff;
}

.concluido {
	background-color: #8FBC8F;
	color: #fff;
}

.ui-selectcheckboxmenu-trigger.ui-state-default.ui-corner-right {
	border:none;
}

.ui-datatable.borderless thead th,
.ui-datatable.borderless tbody,
.ui-datatable.borderless tbody tr,
.ui-datatable.borderless tbody td {
    border-style: solid;
    border-width: thin;
    border-color: #000;
}


</style>



		<p:panelGrid columns="10" style="font-size: 12px;">
			<p:outputLabel value="Nº do Compromisso:" />
			<p:inputText value="#{compromissoBean.idCompromissoFiltro}"
				style="width: 101px;" />

			<p:outputLabel value="#{msgs['campos.titulo.responsavel']}" />

			<p:selectCheckboxMenu value="#{compromissoBean.listaResponsavelString}"
				label="Selecione" filter="true" filterMatchMode="contains" style="margin-top:10px;">
				
				<f:selectItems value="#{compromissoBean.listapessoas}" />
			</p:selectCheckboxMenu>
			<p:outputLabel value="Reuniões:" />

			<p:selectCheckboxMenu value="#{compromissoBean.listaReuniaoString}"
				label="Selecione" filter="true" filterMatchMode="contains" style="margin-top:10px;"
				panelStyle="width: 450px;">
				<f:selectItems value="#{compromissoBean.listaReunioes}" />
			</p:selectCheckboxMenu>




			<p:outputLabel value="#{msgs['campos.titulo.status']}" />

			<p:selectCheckboxMenu value="#{compromissoBean.listaStatusString}"
								label="Selecione" filter="true" filterMatchMode="contains" style="margin-top:10px;">
				
				<f:selectItem itemLabel="Atrasado" itemValue="Atrasado" />
				<f:selectItem itemLabel="Concluido" itemValue="Concluido" />


				<f:selectItem itemLabel="Pendente" itemValue="Pendente" />
				<f:selectItem
					itemLabel="#{msgs['campos.combobox.status.solicitado']}"
					itemValue="Solicitado"></f:selectItem>


			</p:selectCheckboxMenu>

			<p:outputLabel value="Gerências:" />

			<p:selectCheckboxMenu value="#{compromissoBean.listaGerenciaString}"
				label="Selecione" filter="true" filterMatchMode="contains" style="margin-top:10px;">
		
				<f:selectItems value="#{compromissoBean.listaGerencia}">


				</f:selectItems>
			</p:selectCheckboxMenu>
	</p:panelGrid>

		<br></br>
		<br></br>
				<p:dataTable value="#{compromissoBean.listaCompromisso}" var="_lista"
			paginator="true" rows="100" id="tabela"
			emptyMessage="Nenhum registro encontrado" styleClass="borderless"
			rowStyleClass="#{_lista.coresStatus eq 1 ? 'pedente' : null} #{_lista.coresStatus eq 4 ? 'concluido' : null}  #{_lista.coresStatus eq 3 ? 'atrasado' : null} #{_lista.coresStatus eq 2 ? 'proximoMeta' : null} #{_lista.coresStatus eq 5 ? 'solicitado' : null} "
			
			>

			<p:column style="widh: 20px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Número" />
			</f:facet>
			
				<p:outputLabel value="#{_lista.numeroCompromisso}" />
			</p:column>
			<p:column  style="widh: 50px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Reunião " />
			</f:facet>
			
				<p:outputLabel value="#{_lista.reuniao.nome}">
					<f:convertDateTime pattern="dd/MM/yyyy hh:mm" timeZone="GMT-03:00" />
				</p:outputLabel>
			</p:column>
			
			<p:column style="widh: 50px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Data da Reunião" />
			</f:facet>
			
				<p:outputLabel value="#{_lista.reuniao.dataReuniao}">
					<f:convertDateTime pattern="dd/MM/yyyy hh:mm" timeZone="GMT-03:00" />
				</p:outputLabel>
			</p:column>

			<p:column headerText="Meta" style="widh: 50px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Meta" />
			</f:facet>
			
				<p:outputLabel value="#{_lista.metaConclusao}">
					<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-03:00" />

				</p:outputLabel>
			</p:column>

			


			<p:column headerText="Status" style="widh: 70px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Status" />
			</f:facet>
			
				<p:outputLabel value="#{_lista.status}" />
			</p:column>





			<p:column headerText="Responsável" style="widh: 140px;" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Responsável " />
			</f:facet>
			
				<p:outputLabel value="#{_lista.pessoa.nome}" />
			</p:column>


			<p:column headerText="Solicitante" style="widh: 140px;" exportable="false">
				<p:outputLabel value="#{_lista.solicitante.nome}" />
			</p:column>


			<p:column headerText="Descrição" exportable="true">
			
			<f:facet name="header">
				<h:outputText value="Descrição " />
			</f:facet>
			
				<p:outputLabel value="#{_lista.descricao}" />
			</p:column>



			<p:column headerText="#{msgs['campos.titulo.acoes']}"
				style="width: 140px;" exportable="false">

				<!-- Alterar Status Para Pendente -->
				<p:commandButton icon="ui-icon-lightbulb" style="width: 20px;"
					title="Alterar status para Pendente" onclick="PF('dialog').show();"
					rendered="#{_lista.status eq 'Solicitado'}">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />
				</p:commandButton>

				<!-- Editar Compromisso -->
				<p:commandButton icon="ui-icon-wrench"
					style="width: 20px;"
					title="Editar Compromisso"
					action="#{compromissoBean.preRevisaCompromisso()}">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />
				</p:commandButton>



				<!-- Rejeitar Solicitação de Conclusão -->
				<p:commandButton icon="ui-icon-grip-diagonal-se"
					rendered="#{(_lista.status eq 'Atrasado') or (_lista.status eq 'Pendente')}"
					style="width: 20px;" title="Rejeitar Solicitação de Conclusão"
					action="#{compromissoBean.preRejeitaSolicitacaoDeCompromisso()}">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />
				</p:commandButton>



				<!-- Concluir Compromisso -->
				<p:commandButton icon="ui-icon-check" style="width: 20px;"
					rendered="#{(_lista.status eq 'Atrasado') or (_lista.status eq 'Pendente')}"
					action="#{compromissoBean.preatualizarSituacaoCompromissoConcluido()}"
					ajax="false" title="Concluir Compromisso">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />
				</p:commandButton>



				<!-- Cancelar Compromisso -->
				<p:commandButton icon="ui-icon-cancel" style="width: 20px;"
					rendered="#{!_lista.status.equals('Concluido')}"
					action="#{compromissoBean.recusarCompromisso()}" ajax="false"
					title="Cancelar Compromisso">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />
				</p:commandButton>


				<!-- Visualizar Compromisso -->
				<p:commandButton icon="ui-icon-search" style="width: 20px;"
					action="#{compromissoBean.listarCompromissoConcluidoSelecionado()}"
					title="Visualizar Compromisso">
					<f:setPropertyActionListener
						target="#{compromissoBean.compromisso}" value="#{_lista}" />

				</p:commandButton>



			</p:column>
		</p:dataTable>

		<p:dialog id="basicDialog" style="width: 2000px;" widgetVar="dialog"
			resizable="false">
			<h4>Deseja alterar o status para Pendente?</h4>
			<p:commandButton value="Sim"
				action="#{compromissoBean.alterarStatusPendente()}" ajax="false"
				style="width: 81px; margin-top: 25px;"></p:commandButton>
			<p:commandButton value="Não" onclick="PF('dialog').hide();"
				style="width: 81px; margin-left: 20px;"></p:commandButton>

		</p:dialog>


	</ui:define>
</ui:composition>
</html>